package eval.vm;

import com.google.inject.Inject;

public class VMFactory implements IVMFactory {

	private IVMManager vmManager;

	private int idCounter = 0;

	 @Inject
	public VMFactory(IVMManager vmManager) {
		this.vmManager = vmManager;
	}

	public VirtualMachine createNewVirtualMachine(int lifeTime) {
		//ALFA ver. create only small vm
		//TODO add large etc.
		return createNewVirtualMachine(VMConfigurationEnum.SMALL,lifeTime);
	}

	@Override
	public VirtualMachine createNewVirtualMachine(VMConfigurationEnum vmType,int lifeTime) {
		VMConfiguration vmConfiguration = vmManager.getVMConfigurationForEnum(vmType);
		VirtualMachine vm = new VirtualMachine(idCounter++, vmType,vmConfiguration,lifeTime);
		vmManager.addKnownVM(vm);
		return vm;

	}
}
